<template>
  <div class="basic_info">
    <div class="info_operation_btn">
      <div class="btn_left">
        <el-button
          v-if="isOpenAccount && storeLength > 0"
          :type="[5, 10, 15, 20, 30].includes(orderState) ? 'primary' : ''"
          @click="onNewOreder"
          >新单(N)
        </el-button>
        <el-button v-else class="disabled_button" disabled>新单(N)</el-button>
        <el-button
          v-if="isOpenAccount"
          :disabled="[5, 10, 15, 20, 30].includes(orderState)"
          :class="[5, 10, 15, 20, 30].includes(orderState) ? 'disabled_button' : ''"
          :type="orderState == -1 ? 'primary' : ''"
          @click="onSubmit"
          >保存(S)
        </el-button>
        <el-button v-else class="disabled_button" disabled>保存(S)</el-button>
        <!-- 目前审核按钮为灰色，不用审核 -->
        <el-button disabled class="disabled_button">审核(A) </el-button>
        <!-- <el-button v-if="buttonsPermissions.ShenHe" :disabled="[-1, 5, 10, 15, 20, 25, 30].includes(orderState)"
          :class="[-1, 5, 10, 15, 20, 25, 30].includes(orderState) ? 'disabled_button' : ''"
          :type="[0].includes(orderState) ? 'primary' : ''" @click="onToExamine">审核(A)
        </el-button>
        <el-button v-else class="disabled_button" disabled>审核(A)</el-button> -->
        <el-select v-model="operationValue">
          <el-option
            @click.native="operationSelect(item)"
            v-for="item in operationData"
            :key="item.value"
            :label="item.label"
            :value="item.value"
            :disabled="item.disabled"
            :style="item.disabled ? 'pointer-events: none' : ''"
          ></el-option>
        </el-select>
        <el-button
          :disabled="!isOpenAccount || (orderState != -1 && orderState != 0)"
          :class="!isOpenAccount || (orderState != -1 && orderState != 0) ? 'disabled_button' : ''"
          @click="importExcel"
          >导入</el-button
        >
        <!-- <el-select v-model="importValue">
          <el-option v-if="isOpenAccount" :disabled="[5, 10, 15, 20, 30].includes(orderState)" label="导入"
            value="导入" @click.native="importExcel"
            :style="[5, 10, 15, 20, 30].includes(orderState) ? 'pointer-events: none' : ''"></el-option>
          <el-option v-else disabled label="导入" value="导入" style="pointer-events: none"></el-option>
          <el-option :disabled="orderState == -1" label="导出" value="导出"
            @click.native="exportExcel" :style="orderState == -1 ? 'pointer-events: none' : ''"></el-option>
        </el-select> -->
        <el-button
          :disabled="orderState == -1"
          :class="orderState == -1 ? 'disabled_button' : ''"
          @click="handleShortcutKeyPrint"
          >打印(P)
        </el-button>
        <img v-if="orderState == 5" style="width: 50px; height: 38px; margin-right: 10px" src="@/assets/shenhe.png" />
        <img
          v-else-if="orderState == 10"
          style="width: 57px; height: 43px; margin-right: 10px"
          src="@/assets/zuofei.png"
        />
        <img
          v-else-if="orderState == 20"
          style="width: 57px; height: 24px; margin-right: 10px"
          src="@/assets/hongchong.png"
        />
        <span v-else style="color: #1993fb; margin-right: 10px">{{ getOrderStatusText(orderState) || '未保存' }}</span>
        <!-- <span style="color: #1993fb" v-if="orderState == -1">未保存</span>
        <span style="color: #1993fb" v-else-if="orderState == 0">待审核</span>
        <span style="color: #fd6c21" v-else-if="orderState == 5">已审核</span>
        <span style="color: #ff0000" v-else-if="orderState == 10">已作废</span>
        <span style="color: #ff0000" v-else-if="orderState == 15">已反审</span>
        <span style="color: #ff0000" v-else-if="orderState == 20">已红冲</span>
        <span style="color: #ff0000" v-else-if="orderState == 25">已终止</span>
        <span style="color: #fd6c21" v-else-if="orderState == 30">已完成</span> -->
      </div>
      <div class="btn_right">
        <div style="width: 75px; display: flex; justify-content: space-between" ref="guide8">
          <el-tooltip effect="dark" content="上一条" :enterable="false" placement="top">
            <el-button @click="onUpper" class="arrow_btn" :loading="upperLoading" icon="el-icon-arrow-left"></el-button>
          </el-tooltip>
          <el-tooltip effect="dark" content="下一条" :enterable="false" placement="top">
            <el-button
              @click="onLower"
              class="arrow_btn"
              :loading="lowerLoading"
              icon="el-icon-arrow-right"
            ></el-button>
          </el-tooltip>
        </div>

        <div class="search_order">
          <span>单据编号：</span>
          <el-input v-model="queryData.orderNumber" disabled></el-input>
        </div>
        <!-- <el-checkbox :disabled="isSupplementCheck" v-model="queryData.isSupplement">补单</el-checkbox> -->
      </div>
    </div>
    <div class="info_content_div">
      <div class="div_table">
        <div class="div_screen">
          <div class="custom_left bill_mask_back_view">
            <div v-if="maskViewStatus" class="bill_mask_view"></div>
            <!-- 仓库 -->
            <div class="custom_item">
              <div class="custom_star">
                <div class="custom_label" style="width: auto; min-width: 50px">仓库</div>
                <span class="star">*</span>
              </div>
              <div class="custom_select_head">
                <el-select
                  v-model="queryData.xghStorehouseId"
                  style="width: 100%"
                  filterable
                  ref="deptSelect"
                  @visible-change="(value) => handleFilterMethod('', 'storehouseName')"
                  :filter-method="(value) => handleFilterMethod(value, 'storehouseName')"
                  @change="onClickStorehouse"
                  :disabled="orderState == 0"
                >
                  <el-option
                    v-for="item in storehouseOptions"
                    :key="item.id"
                    :label="item.storehouseName"
                    :value="item.id"
                  ></el-option>
                  <el-option v-if="isOpenAccount" key label value>
                    <div class="custom_add" @click.stop="onStorehouseAdd">
                      <i class="el-icon-plus"></i>
                      <span>新增</span>
                    </div>
                  </el-option>
                </el-select>
              </div>
            </div>
            <!-- 经手人 -->
            <div class="custom_item">
              <div class="custom_star">
                <div class="custom_label" style="width: auto; min-width: 40px">经手人</div>
              </div>
              <div class="custom_select_head">
                <el-select
                  v-model="queryData.sysUserId"
                  style="width: 100%"
                  filterable
                  ref="sysUserSelect"
                  @visible-change="(value) => handleFilterMethod('', 'realname')"
                  :filter-method="(value) => handleFilterMethod(value, 'realname')"
                >
                  <el-option
                    v-for="item in jsrOptions"
                    :key="item.id"
                    :label="item.realname"
                    :value="item.id"
                  ></el-option>
                  <el-option key label value>
                    <div class="custom_add" @click.stop="onShowStaffAdd">
                      <i class="el-icon-plus"></i>
                      <span>新增</span>
                    </div>
                  </el-option>
                </el-select>
              </div>
            </div>
            <div class="custom_item">
              <span v-if="isOpenAccount" class="open-account">开账后只能查看原始单据，不能保存/编辑</span>
            </div>
          </div>
          <!-- 调整日期 -->
          <div class="custom_item">
            <div class="custom_star">
              <div class="custom_label" style="width: auto; min-width: 50px">调整日期</div>
            </div>
            <div class="custom_select_head_time">
              <el-date-picker
                :disabled="isDate"
                v-model="queryData.putTime"
                type="date"
                style="height: 30px"
                value-format="yyyy-MM-dd"
              ></el-date-picker>
            </div>
          </div>
          <!-- 列配置按钮 -->
          <div class="screen_right" ref="guide9">
            <i @click="onShowColumn()" class="set_up el-icon-s-tools" :size="20"></i>
          </div>
        </div>
        <div class="table_content">
          <div>
            <NewTable
              ref="newTableRef"
              :TableConfig="TableConfig"
              :StorehouseList="ckOptions"
              orderType="qckclr"
              :storehouseId="queryData.xghStorehouseId"
              @onDeleteRowPlus="onDeleteRowPlus"
              @onHandleSpData="onHandleSpData"
              @onHandleUnit="onHandleUnit"
              @onHandleAllPrice="onHandleAllPrice"
              @onCheckStorehouse="onCheckStorehouse"
              :table-disabled="maskViewStatus"
              :isDrag="true"            
              ></NewTable>
          </div>
        </div>
        <div class="table_calculation">
          <div class="bill_mask_back_view">
            <p class="table_cal_p">备注</p>
            <span>：</span>
            <el-tooltip :content="queryData.remark" placement="top" :disabled="!queryData.remark">
              <el-input v-model="queryData.remark" :disabled="maskViewStatus"></el-input>
            </el-tooltip>
          </div>
          <div class="bill_mask_back_view">
            <div v-if="maskViewStatus" class="bill_mask_view"></div>
            <p class="table_cal_p">附记</p>
            <span>：</span>
            <el-input v-model="queryData.postscript"></el-input>
          </div>
          <div>
            <p>制单人</p>
            <span>：</span>
            <span>{{ queryData.createName }}</span>
            <p class="table_p_date">制单日期：</p>
            <span>{{ queryData.createOrderDate.substring(0, 10) }}</span>
            <el-button plain @click="onShowLog">操作日志</el-button>
          </div>
        </div>
      </div>
    </div>
    <!-- 列配置弹框 -->
    <CConfiguration
      ref="setColumnRef"
      :columnDataArr="getColumnList"
      :defaultColumnDataArr="defaultColumnData"
      orderType="期初库存录入"
      @onSaveColumn="onSaveColumn"
    ></CConfiguration>
    <!-- 仓库列表查询 -->
    <DialogWarehouseQuery ref="warehouseRef" @onSelectStoreHouse="onSelectStoreHouse"></DialogWarehouseQuery>
    <!-- 新增仓库弹框 -->
    <DialogWarehouseAdd ref="warehouseAddRef" :newData="newWhData" @onAddSubmit="onAddWh" @handleClose="onCloseAddWh">
    </DialogWarehouseAdd>
    <!-- 员工列表查询 -->
    <DialogStaffQuery ref="staffQueryRef" @onSelectStaff="onSelectStaff"></DialogStaffQuery>
    <!-- 新增员工弹框 -->
    <DialogStaffAdd ref="staffAddRef" @dialogVisibleClose="onCloseAddStaff" @onAddSubmit="onAddStaff"></DialogStaffAdd>
    <!-- 操作日志 -->
    <DialogOperationLog :logTitle="logTitle" ref="operationLogRef"></DialogOperationLog>
    <!-- 提醒弹框 -->
    <DialogSimplePrompt ref="simplePrompt" @onSure="onSureSimple"></DialogSimplePrompt>
    <!-- 导入 -->
    <DialogImport
      ref="daoru"
      :titles="TableConfig.columnData"
      :storehouseId="queryData.xghStorehouseId"
      url="/xghInitialInventory/xghInitialInventory/importExcel"
      @importData="importData"
      @downloadTemplate="exportExcel"
    ></DialogImport>
    <!-- 打印 -->
    <dialog-print ref="print"></dialog-print>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'

// 列配置
import CConfiguration from '@/components/c_column/columnConfiguration1'
// 仓库查询
import DialogWarehouseQuery from '../../components/dialogWarehouseQuery'
// 仓库新增
import DialogWarehouseAdd from '../../components/dialogWarehouseAdd'
// 经手人查询
import DialogStaffQuery from '../../components/dialogStaffQuery'
import DialogSimplePrompt from '../../components/dialogSimplePrompt'
import DialogStaffAdd from '../../components/dialogStaffAdd'
/**打印 */
import dialogPrint from '../../components/dialogPrintStock.vue'
import DialogOperationLog from '../../components/dialogOperationLog'
import NewTable from '@/components/c_table/stockBillTable'
import DialogImport from '@/components/c_Import/index1'
import { getAction, postAction, putAction, downPostFile } from '@/api/manage'
// 导入调用处理权限数据方法
import {
  handlePermissions,
  handleOtherPerms,
  getSystemParamsByName,
  formatMoney,
  formatPrice,
  formatNumber,
  formatFour,
  delcommafy,
  handleArrayToObject,
  handleObjectToArray,
  getBasicUnitId,
  getAttributeOrderInfoRequest
} from '@/utils/index'
import { getTimeYMD, getTime, getTimeHMS } from '@/utils/DateFormatter'
import { cloneObject } from '@/utils/util'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'

export default {
  name: 'inventoryEntry',
  components: {
    CConfiguration,
    DialogWarehouseQuery,
    DialogWarehouseAdd,
    DialogStaffQuery,
    DialogStaffAdd,
    DialogOperationLog,
    NewTable,
    DialogImport,
    DialogSimplePrompt,
    dialogPrint,
  },
  mixins: [JeecgListMixin],
  computed: {
    ...mapGetters(['isSupplementOrder']),
    getColumnList() {
      return handleObjectToArray(this.TableConfig.columnData, 'props')
    },
    isSupplementCheck() {
      // 判断补单权限
      if (this.isSupplementOrder) {
        // 已经生成单据编号不能进行补单
        if (!this.queryData.id) {
          return false
        }
      }
      return true
    },
    isDate() {
      // 单据已经保存日期不能修改
      if (this.queryData.id) {
        return true
      }
      return !this.queryData.isSupplement
    },
    maskViewStatus() {
      return this.orderState > 0 || !this.isOpenAccount
    },
    printPermissions() {
      return handleOtherPerms('单据可多次打印')
    },
    buttonsPermissions() {
      return handlePermissions('期初库存录入')
    },
    storeAdd() {
      return handlePermissions('仓库信息').LuRu
    },
  },
  created() {
    // this.buttonsPermissions = handlePermissions('期初库存录入')
    // this.storeAdd = handlePermissions('仓库信息').LuRu

    // 初始化数据
    this.init()
    // 页面跳转的数据处理
    if (this.$route.params.data) {
      this.$nextTick(() => {
        this.$refs.newTableRef.getSubData()
        this.handleData(this.$route.params.data)
      })
    } else if (this.$route.params.billId) {
      this.$nextTick(() => {
        this.$refs.newTableRef.getSubData()
        this.getById(this.$route.params.billId)
      })
    } else {
      //开新单
      this.onOrederDefault()
    }
    this.getOpenAccountFlag()
  },
  mounted() {
    // 监听接收消息
    const that = this
    this.$EventBus.$on('addInventoryInfos', function (res) {
      setTimeout(() => {
        // 仓库信息-下拉框初始化
        that.getStorehouseOptions()
        // 更新一下当前页面数据
        that.getOrderData()
      }, 300)
    })
  },
  beforeDestroy() {
    this.$EventBus.$off('addInventoryInfos')
  },
  watch: {
    orderState: {
      immediate: true,
      handler() {
        this.handleOperationData()
      },
    },
    'queryData.isSupplement'(val) {
      if (!val) {
        // 不补单，时间默认是当天
        this.queryData.putTime = getTime()
      }
    },
    // 路由变化时，更新数据
    $route: {
      immediate: true,
      handler(val) {
        if (val.name === 'baseInfomation-beginningOfPeriod-inventoryEntry' && this.orderState <= 0) {
          // 初始化数据
          this.initData()
          // 仓库信息-下拉框初始化
          this.getStorehouseOptions()
          // 经手人信息-下拉框初始化
          this.getStaffData()
          // 获取开账方式
          this.getOpenAccountFlag()
          // 获取录入数据标记
          this.getEnterDataMarkers()
        }
      },
    },
  },
  data() {
    return {
      form: {},
      storehouseId: '',
      // 传递给操作日志的值
      logData: {
        orderId: -1,
        orderType: '期初库存录入',
      },
      logTitle: '',
      simpleMark: '',
      operationValue: '操作',
      operationData: [
        {
          value: '作废',
          label: '作废',
          disabled: false,
        },
        {
          value: '红冲',
          label: '红冲',
          disabled: false,
        },
      ],
      importValue: '导入',
      // 仓库
      storehouseOptions: [],
      // 入货仓库
      ckOptions: [],
      // 经手人
      jsrOptions: [],
      // 新增仓库数据
      newWhData: {},
      // 新增经手人数据
      newStaffData: {},
      // 查询条件数据
      queryData: {
        id: '', // 单据id
        orderNumber: '', // 单据编号
        isSupplement: false, // 补单
        isReplacementOrder: '1', // 后端参数 补单 0-是 1-否
        putTime: '', //调整时间
        xghStorehouseId: '', // 仓库id
        xghStorehouseId_dictText: '', // 仓库名称
        sysUserId: '', //经手人id
        remark: '', //备注
        postscript: '', //附记
        createName: '', //制单人
        createOrderDate: '', //制单日期（当前日期）
        billOrderStatus: '', //单据状态  0.待审核 5.审核通过 10.作废 15.反审 20.红冲 25.终止 30.完成
      },
      currentPage: 1, //默认开始页面
      showLiepeizhi: false, //是否显示列配置
      scanCode: '',

      newData: {}, // 新增供应商数据
      // 主表格配置
      TableConfig: {
        // 表头数据
        columnData: {
          idx: {
            isShow: true,
            cellWidth: '70px',
            morenName: '序号',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            noModify: true,
            props: 'idx',
          },
          goodsNumber: {
            isShow: true, //是否显示当前列
            showLength: true,
            cellWidth: '150px',
            morenName: '商品编码',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            noModify: true,
            props: 'goodsNumber',
          },
          goodsCode: {
            isShow: true,
            cellWidth: '150px',
            morenName: '条形码',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            noModify: false,
            props: 'goodsCode',
          },
          goodsName: {
            isShow: true,
            isRequired: true,
            showType: 'table',
            cellWidth: '200px',
            morenName: '商品名称',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            noModify: true,
            props: 'goodsName',
          },
          norms: {
            isShow: true,
            cellWidth: '150px',
            morenName: '规格',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'norms',
          },
          unit: {
            isShow: true,
            showType: 'selectDw',
            cellWidth: '150px',
            morenName: '单位',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'unit',
          },
          numberShow: {
            isShow: true,
            showType: 'input',
            isSum: true,
            sumValue: 0,
            cellWidth: '150px',
            morenName: '库存数量',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'numberShow',
          },
          costPriceShow: {
            isShow: true,
            showType: 'input',
            cellWidth: '150px',
            morenName: '成本价',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'costPriceShow',
          },
          stockPriceShow: {
            isShow: true,
            showType: 'input',
            isSum: true,
            sumValue: 0,
            cellWidth: '150px',
            morenName: '库存金额',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'stockPriceShow',
          },
          assistUnit: {
            isShow: true,
            showType: 'selectDw',
            cellWidth: '150px',
            morenName: '辅助单位2',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'assistUnit',
          },
          assistNumberShow: {
            isShow: true,
            cellWidth: '150px',
            morenName: '辅助单位数量2',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'assistNumberShow',
          },
          remark: {
            isShow: true,
            showType: 'input',
            cellWidth: '100px',
            morenName: '备注',
            zidingyiName: '',
            morenState: true,
            zidingyiState: true,
            props: 'remark',
          },
        },
        // 表格数据
        tableData: [],
      },
      defaultColumnData: [], // 默认列配置
      columnKey: '期初库存录入', // 列配置的标识key
      pageSize: 1, // 每页条数
      pageNo: 0, // 触发上一单/下一单的状态
      orderTotal: -1, //总页码
      orderFlag: 0, //  上一单1  下一单2
      buttonStatus: 0, // 上一单/下一单状态的判断
      orderState: -1, // 当前单据的执行状态 -1新单 0.待审核 5.审核通过 10.作废 15.反审 20.红冲 25.终止 30.完成
      updateId: '', // 修改列配置时返回的id
      /**单据保存后立即开新单 */
      isSaveNewOrder: false,
      /**单据保存后立即审核 */
      isSaveExamine: false,
      /**单据审核后立即开新单 */
      isExamineNewOrder: false,
      deleteList: [], // 编辑单据删除商品数据
      insertList: [], // 编辑单据增加商品数据
      updateList: [], // 编辑单据修改商品数据
      infoList: [], // 单据原有的商品数据
      upperLoading: false, // 上一单加载进度
      lowerLoading: false, // 下一单加载进度
      url: {
        exportXlsUrl: '/xghInitialInventory/xghInitialInventory/exportXls',
      }, // 导出地址
      dataLoading: false, // 数据请求状态
      isOpenAccount: false, // 开账后不能修改
      printData: {},
      storeLength: 0, // 仓库列表条数
    }
  },
  methods: {
    // 新增
    handleShortcutKeyAdd() {
      if (this.isOpenAccount) {
        if (this.storeLength > 0) {
          this.onNewOreder()
        } else {
          this.showTips('没有多余的仓库，不能录入新单！')
        }
      } else {
        this.showTips('开单后期初库存录入单不能录入新单！')
      }
    },
    // 保存
    handleShortcutKeySave() {
      if (this.isOpenAccount) {
        this.onSubmit()
      } else {
        this.showTips('开单后期初库存录入单不允许保存！')
      }
    },
    // 审核
    handleShortcutKeyExamine() {
      this.showTips('期初库存录入单不支持审核！')
      // this.onToExamine()
    },
    // 打印
    handleShortcutKeyPrint() {
      console.log('快捷键打印')
      if (this.orderState == -1) {
        this.showTips('当前状态不支持打印操作！')
      } else {
        // 可以多次打印设置
        if (this.printPermissions) {
          this.$refs.print.show(this.printData, this.columnData, this.columnKey)
        } else {
          if (this.$lcStorage.get('printLimitValue')) {
            // 获取打印次数
            this.getPrintNum(this.billId, () => {
              this.$refs.print.show(this.printData, this.columnData, this.columnKey)
            })
          } else {
            this.$refs.print.show(this.printData, this.columnData, this.columnKey)
          }
        }
      }
    },
    // 获取数据
    init() {
      // 获取系统配置参数
      // this.getSystemParamsInfo();
      // 仓库信息-下拉框初始化
      this.getStorehouseOptions()
      // 经手人信息-下拉框初始化
      this.getStaffData()
      // 初始化列配置数据
      this.defaultColumnData = handleObjectToArray(this.TableConfig.columnData)
      this.selectTitle()
    },
    initData() {
      //初始化数据状态
      this.pageNo = 0
      this.orderTotal = -1
      this.orderFlag = 0
      this.logData.orderId = -1
    },
    // 通过ID获取单据
    getById(id) {
      getAction('/xghInitialInventory/xghInitialInventory/getById', { id }).then((res) => {
        if (res.code === 200) {
          this.handleData(res.result)
        }
      })
    },
    // 仓库信息-下拉框初始化 获取还没有期初数据的仓库列表
    getStorehouseOptions() {
      getAction('/xghInitialInventory/xghInitialInventory/unUseStorehouse', {}).then((res) => {
        if (res.code === 200) {
          this.storehouseOptions = res.result
          this.totalStores = this.storehouseOptions
          this.storeLength = this.storehouseOptions.length
        } else {
          this.showTips(res.message, 2)
        }
      })
    },
    // 选择仓库时触发
    onClickStorehouse(value) {
      this.queryData.xghStorehouseId_dictText = this.storehouseOptions.find((item) => item.id === value).storehouseName
    },
    getSystemParamsInfo() {
      this.isSaveNewOrder = getSystemParamsByName('isSaveNewOrder')
      this.isSaveExamine = getSystemParamsByName('isSaveExamine')
      this.isExamineNewOrder = getSystemParamsByName('isExamineNewOrder')
    },
    // 经手人信息-下拉框初始化
    getStaffData() {
      getAction('/dept/xghAccountBookDept/getAllDeptUsers', {}).then((res) => {
        if (res.code === 200) {
          this.jsrOptions = res.result
          this.totalPersons = res.result
        }
      })
    },
    // 查询保存的列配置
    async selectTitle() {
      let obj = await this.$setColumn.selectColumn(this.columnKey)
      if (obj.code === 200) {
        this.updateId = obj.updateId
        this.TableConfig.columnData = obj.columnData
      } else if (obj.code === 500) {
        let id = await this.$setColumn.addColumn(this.columnKey, handleArrayToObject(this.defaultColumnData, 'props'))
        this.updateId = id
        this.TableConfig.columnData = handleArrayToObject(this.defaultColumnData, 'props')
      } else if (obj.code === 404) {
        this.TableConfig.columnData = handleArrayToObject(this.defaultColumnData, 'props')
      }
    },
    // 修改列配置后保存修改后的值
    async onSaveColumn(value) {
      this.TableConfig.columnData = handleArrayToObject(value, 'props')
      let res = await this.$setColumn.editColumn(this.columnKey, this.TableConfig.columnData, this.updateId)
      if (res.code == 200) {
        this.showTips(res.message, 0)
      } else {
        this.showTips(res.message, 2)
      }
    },
    // 处理操作下拉列表的启用禁用项
    handleOperationData() {
      // 导入导出设置
      if (this.orderState < 5) {
        this.importValue = '导入'
      } else {
        this.importValue = '导出'
      }
      // 重置操作权限
      this.operationData.forEach((item) => {
        item.disabled = true
      })
      // 0.待审核 5.审核通过 10.作废 15.反审 20.红冲 25.终止 30.完成
      // 操作只有作废和红冲
      if (this.orderState == 0 && this.isOpenAccount) {
        // 待审核
        this.operationData[0].disabled = !this.buttonsPermissions.ZuoFei
      } else if (this.orderState == 5) {
        // 红冲一直灰色，没有红冲操作
        // this.operationData[1].disabled = !this.buttonsPermissions.HongChong;
      }
    },
    isSave() {
      // 判断当前单据的数据是否保存
      if (
        this.orderState === -1 &&
        (this.queryData.xghStorehouseId ||
          this.queryData.sysUserId ||
          this.queryData.remark ||
          this.queryData.postscript)
      ) {
        return true
      }
      return false
    },
    // 点击开新单
    onNewOreder() {
      // 1.先判断当前页面的值是否保存，用弹出框给用户提醒
      if (this.isSave()) {
        this.simpleMark = 'onNewOreder'
        this.onShowTipsDialog('当前单据还未保存，</br>是否继续？')
      } else {
        this.onOrederDefault()
      }
    },
    onOrederDefault() {
      // 设置新单的默认数据
      this.orderState = -1
      this.queryData = this.$options.data().queryData
      this.queryData.putTime = getTime()
      this.queryData.createOrderDate = getTime()
      this.queryData.createName = this.$lcStorage.get('xghUser').realname
      this.initData()
      this.onEditClear()
      this.storeLength = 0
      this.getStorehouseOptions()
      this.$nextTick(() => {
        this.$refs.newTableRef.getSubData()
      })
    },
    // 保存
    async onSubmit() {
      if (this.dataLoading) {
        this.showTips('请勿重复提交！')
        return
      }
      if (!this.queryData.xghStorehouseId) {
        this.showTips('仓库不能为空，请选择！')
        return
      }
      let summary = ''
      // 如果商品中有名称为空的商品，则不能保存
      const tableDataLength = this.TableConfig.tableData.length
      for (let i = 0; i < tableDataLength; i++) {
        const element = this.TableConfig.tableData[i]
        if (element.goodsId && delcommafy(element.number) <= 0) {
          this.showTips(`[${element.goodsName}]库存数量必须大于0，请输入！`)
          return
        }
        // 拼接摘要信息
        summary += `[${element.goodsName},${formatNumber(element.number)}${element.unit}]`
        if (i != tableDataLength - 1) {
          summary += ';'
        }
      }
      // 转换金额信息
      const newTableData = JSON.parse(JSON.stringify(this.TableConfig.tableData))
      let list = newTableData
        .map((element) => {
          if (element.goodsId) {
            element.costPrice = delcommafy(element.costPrice)
            element.stockPrice = delcommafy(element.stockPrice)
            element.number = delcommafy(element.number)
            element.assistNumber = delcommafy(element.assistNumber)
            // if (this.queryData.id) {
            //   if (!element.id) {
            //     this.insertList.push(element)
            //   } else {
            //     if (this.isListObj(this.infoList, element)) {
            //       this.updateList.push(element)
            //     }
            //   }
            // }
            if (element.attributeOrderInfoRequest) {
							element.attributeOrderInfoRequest.forEach(el => {
								el.orderType = '-1'
								el.mainId = this.queryData.id
								el.price = delcommafy(element.costPrice)
								el.accountBookId = this.xghAccountBookId
								el.inStoreId = this.queryData.xghStorehouseId
								el.inNumber = el.number
							})
						}
            return element
          }
        })
        .filter((item) => {
          return item != undefined
        })
      if (list.length == 0) {
        this.showTips('商品不能为空，请选择商品！')
        return
      }
      let queryObj = cloneObject(this.queryData)
      // 给补单的数据转换为后端需要的类型 0-是 1-否
      queryObj.isReplacementOrder = queryObj.isSupplement ? 0 : 1
      // 给制单人重新赋值
      queryObj.createName = this.$lcStorage.get('xghUser').userName
      // 添加摘要信息
      queryObj.summary = summary
      var res = {}
      // 修改
      if (this.queryData.id) {
        // 先判断用户是否拥有修改权限
        // if (this.buttonsPermissions.XiuGai) {
        // let obj = {
        //   ...queryObj,
        //   insertList: this.insertList,
        //   deleteList: this.deleteList,
        //   updateList: this.updateList
        // }
        let obj = {
          ...queryObj,
          xghInitialInventoryInfoList: list,
        }
        this.setDataLoading(true, false)
        res = await postAction('/openAccount/editOpeningInventory', obj)
        this.onEditClear()
        // } else {
        //   this.showTips('没有修改权限！')
        //   return
        // }
      } else {
        let obj = {
          ...queryObj,
          xghInitialInventoryInfoList: list,
        }
        // 服务端接收的时间需要增加时分秒
        obj.putTime = obj.putTime.length > 11 ? obj.putTime : obj.putTime + ' ' + getTimeHMS()
        // 新增
        this.setDataLoading(true, false)
        res = await postAction('/openAccount/enterOpeningInventory', obj)
      }
      this.setDataLoading(false, true)
      if (res.code === 200) {
        this.onShowSuccess('单据保存成功！')
        this.getStorehouseOptions()
        // if (!this.queryData.id && !this.queryData.isSupplement) {
        //   this.onUpperOrLower(1)
        // }
        this.handleData(res.result)
      } else {
        this.showTips(res.message)
      }
    },
    // 改变网络请求状态
    setDataLoading(loading, val) {
      if (val) {
        setTimeout(() => {
          this.dataLoading = loading
        }, 3000)
      } else {
        this.dataLoading = loading
      }
    },
    isListObj(arr, obj) {
      for (let val of arr) {
        if (val.id == obj.id) {
          for (let key in val) {
            if (val[key] != obj[key]) {
              return true
            }
          }
        }
      }
      return false
    },
    // 单据保存后的走向
    toSaveOrExamine() {
      // 如果保存后立即开新单,并且有新增权限
      if (this.isSaveNewOrder && this.buttonsPermissions.LuRu) {
        this.simpleMark = 'onNewOreder'
        this.onSureSimple()
      } else if (this.isSaveExamine && this.buttonsPermissions.ShenHe) {
        // 保存后立即审核,且有审核权限
        setTimeout(() => {
          this.onToExamine()
        }, 1000)
      }
    },
    afterExamine() {
      // 如果审核后立即开新单
      if (this.isExamineNewOrder && this.buttonsPermissions.LuRu) {
        this.simpleMark = 'onNewOreder'
        this.onSureSimple()
      }
    },
    // 审核单据
    onToExamine() {
      this.simpleMark = 'onToExamine'
      this.onShowTipsDialog('确定要审核当前的单据吗？')
    },
    // 操作选择
    operationSelect(value) {
      this.operationValue = '操作'
      switch (value.label) {
        case '作废':
          this.simpleMark = 'onToVoid'
          this.onShowTipsDialog('确定要作废当前的单据吗？')
          break
        case '复制单据':
          this.simpleMark = 'onCopy'
          this.onShowTipsDialog('确定要复制当前的单据吗？')
          break
        case '办理过程':
          this.$refs.operationLogRef.getData(this.logData)
          this.logTitle = '办理过程'
          this.$refs.operationLogRef.dialogVisible = true
          break
      }
    },
    onSureSimple() {
      switch (this.simpleMark) {
        case 'onNewOreder':
          // 新单 把页面的值都改为初始值
          this.onOrederDefault()
          break
        case 'onUpper':
          // 上一单
          this.onUpperOrLower(1)
          break
        case 'onLower':
          // 下一单
          this.onUpperOrLower(2)
          break
        case 'onToExamine':
          // 审核
          this.onToExamineAudit()
          break
        case 'onToVoid':
          // 作废
          this.onToVoid()
          break
        case 'onCopy':
          // 复制单据
          this.onCopy(true)
          break
      }
    },
    // 导入
    importExcel() {
      // if (this.queryData.xghStorehouseId) {
      this.$refs.daoru.dialogVisible = true
      // } else {
      //   this.showTips('仓库不能为空，请选择！')
      // }
    },
    // 导入数据处理
    importData(val) {
      if (val.success) {
        this.showTips(val.message, 0)
        val.result.records.forEach((item) => {
          let data = {
            goodsNumber: item.goodsNumber,
            goodsCode: item.goodsCode,
            goodsName: item.goodsId_dictText,
            goodsId: item.goodsId,
            goodsTypeId: item.goodsTypeId,
            norms: item.norms,
            unit: item.unit,
            goodsManyNorms: item.goodsManyNorms,
            number: item.number,
            assistNumber: item.assistNumber,
            costPrice: item.costPrice,
            stockPrice: item.stockPrice,
            numberShow: formatNumber(item.number),
            assistNumberShow: formatNumber(item.assistNumber),
            costPriceShow: formatPrice(item.costPrice),
            stockPriceShow: formatMoney(item.stockPrice),
            scale: item.scale,
            basicUnit: getBasicUnitId(item.goodsManyNorms),
            remark: item.remark,
            arrivalNumber: item.arrivalNumber,
            notArrivalNumber: item.notArrivalNumber,
            arrivalNumberShow: formatNumber(item.arrivalNumber),
            notArrivalNumberShow: formatNumber(item.notArrivalNumber),
            assistUnit: item.assistUnit,
          }
          // 替换第一条空数据的商品信息
          if (this.TableConfig.tableData.length == 1 && !this.TableConfig.tableData[0].goodsId) {
            this.TableConfig.tableData.splice(0, 1, data)
          } else {
            let dataArr = this.TableConfig.tableData.filter((item) => item.goodsId === data.goodsId)
            if (dataArr.length === 0) {
              this.TableConfig.tableData.push(data)
            } else {
              this.showTips(`[${data.goodsName}]已经存在，不能重复选择商品！`)
            }
          }
          this.$refs.newTableRef.changeUnit(
            this.TableConfig.tableData.length - 1,
            this.TableConfig.tableData[this.TableConfig.tableData.length - 1]
          )
        })
      } else {
        this.showTips(val.message, 2)
      }
    },
    // 导出
    exportExcel() {
      const fileName = '期初库存录入' + this.queryData.orderNumber
      let params = {
        ...this.queryData,
        fileName,
      }
      this.handleExportXlsByStaff(fileName, params)
    },
    // 上一条
    onUpper() {
      if (this.isSave()) {
        this.simpleMark = 'onUpper'
        this.onShowTipsDialog('当前单据还未保存，</br>是否继续？')
      } else {
        this.onUpperOrLower(1)
      }
    },
    // 下一条
    onLower() {
      if (this.isSave()) {
        this.simpleMark = 'onLower'
        this.onShowTipsDialog('当前单据还未保存，</br>是否继续？')
      } else {
        this.onUpperOrLower(2)
      }
    },
    onUpperOrLower(flag) {
      //记录初始的操作
      if (this.orderFlag === 0) {
        this.orderFlag = flag
      }
      if (flag === 1) {
        // 上一单
        if (
          this.orderTotal === 0 ||
          (this.orderFlag === 1 && this.pageNo === this.orderTotal) ||
          (this.orderFlag === 2 && this.pageNo === 1)
        ) {
          this.showTips('当前已是第一条数据！')
          return
        }
        this.upperLoading = true
        //需要根据第一次点击的按钮进行选择
        if (this.orderFlag === 1) {
          this.pageNo++
        } else {
          this.pageNo--
        }
      } else {
        //下一单
        if (
          this.orderTotal === 0 ||
          (this.orderFlag === 1 && this.pageNo === 1) ||
          (this.orderFlag === 2 && this.pageNo === this.orderTotal)
        ) {
          this.showTips('当前已是最后一条数据！')
          return
        }
        this.lowerLoading = true
        //需要根据第一次点击的按钮进行选择
        if (this.orderFlag === 1) {
          this.pageNo--
        } else {
          this.pageNo++
        }
      }
      this.getOrderData()
    },
    // 打开列配置弹框
    onShowColumn() {
      this.$refs.setColumnRef.dialogVisible = true
    },
    // 审核
    onToExamineAudit() {
      getAction('/xghInitialInventory/xghInitialInventory/audit', {
        id: this.queryData.id,
        billOrderStatus: this.orderState,
      }).then((res) => {
        if (res.code === 200) {
          this.onShowSuccess('审核成功！')
          this.handleData(res.result)
        } else if (res.code === 500) {
          this.showTips(res.message)
        }
      })
    },
    // 作废
    onToVoid() {
      getAction('/openAccount/invalid', {
        id: this.queryData.id,
      }).then((res) => {
        if (res.code === 200) {
          this.onShowSuccess('作废成功！')
          this.handleData(res.result)
        } else if (res.code === 500) {
          this.showTips(res.message)
        }
      })
    },
    onCopy(show) {
      // 复制单据
      this.queryData.id = ''
      this.queryData.orderNumber = ''
      this.queryData.billOrderStatus = ''
      this.TableConfig.tableData.forEach((item) => {
        item.id = ''
      })
      this.orderState = -1
      this.queryData.createOrderDate = getTime()
      this.queryData.createName = this.$lcStorage.get('xghUser').realname
      this.initData()
      if (show) {
        this.onShowDialogSuccess('单据复制成功')
      }
    },
    onCheckStorehouse(index) {
      if (!this.queryData.xghStorehouseId) {
        this.showTips('仓库不能为空，请选择！')
        return
      }
      this.$refs.newTableRef.onShowCommodity(index)
    },
    /**
     * 父组件处理子组件获取到的商品信息数据字段名不统一问题
     * @param tableData 子组件中表格的数据
     * @param index 当前选中this.TableConfig.tableData的索引
     * @param index 从商品表中选中的商品数据
     */
    onHandleSpData(tableData, index, val) {
      this.TableConfig.tableData[index].goodsNumber = val.goodsNumber
      this.TableConfig.tableData[index].goodsCode = val.barCode
      this.TableConfig.tableData[index].goodsId = val.id
      this.TableConfig.tableData[index].goodsName = val.goodsName
      this.TableConfig.tableData[index].norms = val.specs
      this.TableConfig.tableData[index].unit = val.defaultUnit
      this.TableConfig.tableData[index].goodsManyNorms = val.goodsManyNorms
      this.TableConfig.tableData[index].basicUnit = getBasicUnitId(val.goodsManyNorms)
      this.TableConfig.tableData[index].number = (val.specialFunctionType || '').includes('1') ? 0 : 1
      this.TableConfig.tableData[index].arrivalNumber = 0
      this.TableConfig.tableData[index].notArrivalNumber = val.number
      this.TableConfig.tableData[index].remark = val.goodsRemark
      this.TableConfig.tableData[index].xghStorehouseId = this.queryData.xghStorehouseId
      this.TableConfig.tableData[index].costPrice = formatFour(val.costPrice)
      this.TableConfig.tableData[index].costPriceShow = formatPrice(val.costPrice)
      this.TableConfig.tableData[index].goodsTypeId = val.xghGoodsTypeId

      //特殊功能
      this.TableConfig.tableData[index].specialFunctionType = val.specialFunctionType
        this.TableConfig.tableData[index].specialColorSize = (val.specialFunctionType || '').includes('1')
        this.TableConfig.tableData[index].showSpeial = !(val.specialFunctionType || '').includes('1')

      this.$refs.newTableRef.changeUnit(index, this.TableConfig.tableData[index])
    },
    /**
     * 父组件处理子组件获取到的商品单位/价格相关数据
     * @param val 当前选中的单位的值
     * @param index 当前选中this.TableConfig.tableData的索引
     */
    onHandleUnit(val, index) {},
    /**
     * 获取合计列总金额
     * @param value 合计列总金额值
     */
    onHandleAllPrice(value) {},
    /**
     * 获取当前单据数据
     */
    getOrderData() {
      let data = {
        billOrderType: this.queryData.billOrderType,
        pageNo: this.pageNo,
        pageSize: this.pageSize,
        orderFlag: this.orderFlag,
      }
      getAction('/xghInitialInventory/xghInitialInventory/getByPage', data).then(
        (res) => {
          this.upperLoading = false
          this.lowerLoading = false
          if (res.code === 200) {
            this.orderTotal = res.result.pages
            if (this.orderTotal > 0) {
              if (res.result.size === 1) {
                this.handleData(res.result.records[0])
              }
            } else {
              if (this.orderFlag === 1) {
                this.showTips('当前已是第一条数据！')
              } else {
                this.showTips('当前已是最后一条数据！')
              }
              this.pageNo = 0
              this.orderFlag = 0
            }
          }
        },
        (error) => {
          this.upperLoading = false
          this.lowerLoading = false
        }
      )
    },
    // 处理请求到的数据
    handleData(res) {
      this.printData = res
      // 获取订单状态
      this.orderState = Number(res.status)
      // 给id赋值
      this.logData.orderId = res.id
      if (res.infoList) {
        // 记录原始商品数据
        this.infoList = cloneObject(res.infoList)
        const tableData = res.infoList
        // 金额转换
        tableData.forEach((item) => {
          item.costPriceShow = item.costPrice ? formatPrice(item.costPrice) : item.costPrice
          item.stockPriceShow = item.stockPrice ? formatMoney(item.stockPrice) : item.stockPrice
          item.numberShow = item.number ? formatNumber(item.number) : item.number
          item.assistNumberShow = item.assistNumber ? formatNumber(item.assistNumber) : item.assistNumber
          // 特殊功能
          item.attributeOrderInfoRequest = getAttributeOrderInfoRequest(item.attributeGoodsResponse)
          item.specialColorSize = (item.specialFunctionType || '').includes('1')
          item.showSpeial = true
        })
        // 增加字段数据，避免不能更新页面
        this.TableConfig.tableData = cloneObject(tableData)
      } else {
        this.infoList = []
        this.TableConfig.tableData = []
        this.$refs.newTableRef.getSubData()
      }
      this.onEditClear()
      // 给筛选项清空后重新赋值
      this.queryData = this.$options.data.call(this).queryData
      // 处理筛选条件的数据
      for (const key in this.queryData) {
        for (const k in res) {
          if (key === k) {
            this.queryData[key] = res[k]
            if (key == 'isReplacementOrder') {
              this.queryData.isSupplement = parseFloat(res[key]) == 0 ? true : false
            }
          }
        }
      }
      // 仓库回显数据
      this.storehouseOptions = [{ id: res.xghStorehouseId, storehouseName: res.xghStorehouseId_dictText }]
      // 添加打印数据
      this.printData = {
        ...this.queryData,
        xghStorehouseId_dictText: res.xghStorehouseId_dictText,
        printExclusive: this.TableConfig.tableData,
      }
      this.$nextTick(() => {
        if (this.$refs.sysUserSelect) {
          this.printData.sysUserId_dictText = this.$refs.sysUserSelect.selected.label
        }
      })
    },
    // 打开新增仓库的弹框
    onShowWhAdd() {
      this.$refs.warehouseAddRef.dialogVisible = true
    },
    // 新增仓库数据
    async onAddWh(val) {
      val.isMain = val.isMain == true ? 1 : 0
      const res = await postAction('/xghStorehouse/xghStorehouse/add', val)
      if (res.code == 200) {
        // 新增仓库成功之后，刷新仓库下拉框
        this.getStorehouseOptions()
      }
    },
    // 关闭新增仓库时清空新增dialog中的数据
    onCloseAddWh() {
      this.newWhData = this.$options.data().newWhData
    },
    // 打开选择商品弹出框 关闭商品历史记录弹出表
    onShowGoods() {
      this.$refs.popoverRef[0].doClose()
      this.$refs.commodityRef.dialogVisible = true
    },
    // 打开经手人分页查询dialog
    onShowStaff() {
      this.$refs.staffQueryRef.dialogVisible = true
    },
    // 打开新增经手人的弹框
    onShowStaffAdd() {
      this.$refs.staffAddRef.dialogVisible = true
    },
    // 获取新增经手人数据
    onAddStaff(val) {
      postAction('/dept/xghAccountBookDept/addAccountBookUser', val).then((res) => {
        if (res.code === 200) {
          this.getStaffData()
          this.$refs.staffAddRef.dialogVisible = false
        } else {
          this.showTips(res.message)
        }
      })
    },
    // 关闭新增经手人时清空
    onCloseAddStaff() {
      this.newStaffData = this.$options.data().newStaffData
    },
    // 打开操作日志弹框
    onShowLog() {
      this.$refs.operationLogRef.getData(this.logData)
      this.logTitle = '单据操作日志'
      this.$refs.operationLogRef.dialogVisible = true
    },
    // 打开新增仓库弹出框
    onStorehouseAdd() {
      this.newData = {
        id: '',
        storehouseTypeName: '',
        storehouseCode: '',
        pinyinCode: '',
        indexCode: '',
      }
      this.$refs.warehouseAddRef.dialogVisible = true
    },
    // 新增仓库数据
    onAddSupplier(res) {
      this.newData = this.$options.data().newData
      // 2.把当前新增值的仓库名称展示在输入框内
      this.onSelectStoreHouse(res)
      this.$refs.warehouseRef.getData()
    },
    // 打开选择仓库弹出框
    onShowStorehouse() {
      this.$refs.warehouseRef.dialogVisible = true
    },
    // 仓库查询子组件选择了仓库，把值付给父组件
    onSelectStoreHouse(val) {
      this.queryData.xghStorehouseId = val.id
    },
    // 经手人查询子组件选择了经手人，把值付给父组件
    onSelectStaff(val) {
      this.queryData.sysUserId = val.id
    },
    onCloseAddSupplier() {
      this.newData = this.$options.data().newData
    },
    // 新增数据中表格内输入框聚焦时选中
    focusinSelect() {
      event.target.select()
    },
    // 历史记录数据去重并只展示三个数据方法
    selectDataHas(arr) {
      let map = new Map()
      for (const item of arr) {
        if (!map.has(item.id)) {
          map.set(item.id, item)
        }
      }
      let newArr = [...map.values()]
      return newArr.slice(0, 3)
    },
    // 获取期初信息
    getOpenAccountFlag() {
      getAction('/openAccount/getOpenAccountType', {}).then((res) => {
        if (res.code === 200) {
          let val = Number(res.result.value)
          this.$store.commit('SET_OPEN_ACCOUNT_VALUE', val)
          if (val === 3) {
            this.isOpenAccount = false
          } else {
            this.isOpenAccount = true
          }
        }
      })
    },
    // 获取录入数据标记
    getEnterDataMarkers() {
      getAction('/openAccount/getEnterDataMarkers', {}).then((res) => {
        if (res.code === 200) {
          let data = res.result
          data.forEach(item => {
            // 期初库存录入有数据，获取数据
            if(item.code === 'enter_opening_inventory' && item.value === '1'){
              this.onUpperOrLower(2)
            }
          });
        }
      })
    },
    // 删除商品数据
    onDeleteRowPlus(data) {
      if (this.queryData.id && data && data.id) {
        this.deleteList.push(data)
      }
    },
    // 清除数据
    onEditClear() {
      this.insertList = []
      this.deleteList = []
      this.updateList = []
    },
    // 搜索
    handleFilterMethod(value, label) {
      if (label == 'storehouseName') {
        this.storehouseOptions = this.filterMethod(this.storehouseOptions, value, label)
      } else if (label == 'realname') {
        this.jsrOptions = this.filterMethod(this.jsrOptions, value, label)
      }
    },
    getOrderStatusText(os) {
      let object = {
        0: '待审核',
        5: '已审核',
        10: '已作废',
        15: '待审核',
        20: '已红冲',
        25: '已终止',
        30: '已完成',
      }
      return object[os + '']
    },
    onShowTipsDialog(msg) {
      this.$refs.simplePrompt.showTwoBtn('el-icon-warning', msg, '是', '否')
    },
    onShowDialogSuccess(msg) {
      this.simpleMark = ''
      this.$refs.simplePrompt.showOneBtn('el-icon-success', msg, '确定')
    },
    onShowSuccess(msg) {
      setTimeout(() => {
        this.$refs.simplePrompt.show({
          index: 0,
          text: msg,
        })
      }, 500)
    },
    showTips(msg, type = 1) {
      switch (type) {
        case 0:
          this.$elMessage.success(msg)
          break
        case 1:
          this.$elMessage.warning(msg)
          break
        case 2:
          this.$elMessage.error(msg)
          break
      }
    },
  },
}
</script>

<style lang="scss" scoped>
.basic_info {
  width: 100%;
  height: calc(100vh - 1.875117rem);
  background: #f0f2f5;
  box-sizing: border-box;
  padding: 0 0.168761rem 0.168761rem;
  display: flex;
  flex-direction: column;
}

.info_operation_btn {
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: PingFang SC;
  font-size: 12px;
  ::v-deep .el-button {
    width: 70px;
    height: 30px;
    text-align: center;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    border-radius: 0.093756rem;
    border: none;
    margin-right: 6px;
    margin-left: 0;
  }

  .el-button--default {
    color: #666;
  }

  ::v-deep .el-select {
    height: 30px;
    box-sizing: border-box;
    margin-right: 10px;

    .el-input {
      height: 100%;

      .el-input__inner {
        width: 70px;
        height: 100%;
        border: none;
        font-size: 12px;
      }

      .el-input__suffix {
        height: 100%;
        display: flex;
        align-items: center;
      }

      .el-textarea {
        height: 100%;
        width: 30px;
      }
    }
  }

  ::v-deep .el-checkbox {
    display: flex;
    align-items: center;
    margin-left: 10px;

    .el-checkbox__input {
      height: 19px;
      display: flex;
      align-items: center;
    }

    .el-checkbox__label {
      font-size: 12px;
      padding-left: 5px;
      color: #666;
    }

    .is-checked {
      .el-checkbox__inner {
        background: #1a93fa;
        border-color: #1a93fa;
      }
    }
  }

  .arrow_btn {
    width: 30px;
    height: 30px;
    background: #ffffff;
    padding: 0;
    margin-right: 0;
  }

  p {
    font-size: 12px;
    color: #666;
    margin-right: 0.25rem;
  }

  .search_order {
    display: flex;
    align-items: center;
    margin-left: 10px;

    p {
      margin-right: 0;
    }

    ::v-deep .el-input {
      width: 148px;
      height: 30px;

      .el-input__inner {
        height: 30px;
        line-height: 30px;
        padding: 0 5px;
        font-size: 12px;
        background-color: #ffffff;
        border: none;
        color: #666666;
      }
    }
  }

  .btn_left {
    height: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: center;
  }

  .btn_right {
    height: 100%;
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }
}

.info_content_div {
  width: 100%;
  height: calc(100% - 1rem);
  background: #fff;
  box-sizing: border-box;
  padding: 0 0.168761rem;
  display: flex;

  .div_table {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    // justify-content: space-between;

    .div_screen {
      width: 100%;
      // heig ht: 50px;
      display: flex;
      justify-content: space-between;
      align-items: center;

      ::v-deep .el-select {
        height: 30px;
        box-sizing: border-box;
        margin-right: 10px;

        .el-input {
          height: 100%;

          .el-input__inner {
            height: 100%;
            font-size: 12px;
          }

          .el-input__suffix {
            height: 100%;
            display: flex;
            align-items: center;
          }

          .el-textarea {
            height: 100%;
            width: 30px;
          }
        }
      }

      ::v-deep .el-date-editor {
        width: 120px;
        height: 30px;

        .el-input__inner {
          width: 100%;
          height: 30px;
          padding: 0 0.187512rem;
          font-size: 12px;
          color: #666;
        }

        .el-input__prefix {
          left: unset;
          right: 5px !important;

          .el-input__icon {
            line-height: 30px;
            font-size: 16px;
          }
        }

        .el-input__suffix {
          display: none;
        }
      }

      .screen_right {
        width: 30px;
        height: 30px;
        box-sizing: border-box;
        display: flex;
        justify-content: center;
        align-items: center;
        box-sizing: border-box;

        .set_up {
          line-height: 20px;
          font-size: 20px;
          color: rgb(153, 153, 153);
        }
      }
    }

    .table_content {
      flex: 1;
      margin-top: 10px;
      box-sizing: border-box;
      overflow: auto;

      > div {
        width: 100%;
        height: 100%;
        border: 1px solid #e3e3e3;
      }
    }

    .table_calculation {
      width: 100%;
      // height: 3.187699rem;
      height: 50px;
      box-sizing: border-box;
      // padding: 0.187512rem 0;
      padding-top: 10px;
      display: flex;
      justify-content: space-between;

      > div {
        // height: 0.55rem;
        height: 30px;
        margin-bottom: 0.187512rem;
        margin-right: 20px;
        display: flex;
        align-items: center;

        ::v-deep .el-button {
          width: 80px;
          height: 30px;
          display: flex;
          margin-left: 12px;
          align-items: center;
          justify-content: center;
          // font-size: 0.225014rem;
          font-size: 12px;
          color: #666;
          background: #fff;
        }

        > p,
        span {
          margin: 0;
          // font-size: 0.225014rem;
          font-size: 12px;
          color: #666;
        }

        .table_cal_p {
          width: 0.8rem;
          text-align: justify;
          text-justify: distribute-all-lines;
          /*ie6-8*/
          text-align-last: justify;
          /* ie9*/
          -moz-text-align-last: justify;
          /*ff*/
          -webkit-text-align-last: justify;
          /*chrome 20+*/
        }

        > ::v-deep .el-input {
          height: 30px;

          .el-input__inner {
            height: 100%;
            padding: 0 0.150009rem;
            // font-size: 0.225014rem;
            font-size: 12px;
            color: #666;
          }
        }
        .table_p_date {
          margin-left: 12px;
        }
        &:last-child {
          margin-bottom: 0;
          margin-right: 0;
        }
      }

      .bill_mask_back_view {
        flex: 1;
      }
    }
  }
}

.scan_div {
  width: 100%;
  position: relative;
}

.scan_popover {
  position: fixed;
  top: 3.000188rem;
  left: 6rem;
  z-index: 1;
  padding: 0.112507rem;
  background: #fff;
  border: 1px solid #eee;
  display: flex;
  align-items: center;
  box-shadow: 1px 1px 5px 2px rgba(0, 0, 0, 0.2);
  display: none;

  .close_scan {
    position: absolute;
    top: -0.187512rem;
    left: 4.950309rem;
    font-size: 0.337521rem;
    cursor: pointer;
    color: #666;
  }

  ::v-deep .el-input {
    width: 3.375211rem;
    // height: 0.562535rem;
    height: 0.55rem;

    .el-input__inner {
      width: 100%;
      height: 100%;
      border-color: #1893fc;
      border-radius: 0;
      padding: 0 0.112507rem;
    }
  }

  p {
    width: 1.500094rem;
    // height: 0.562535rem;
    height: 0.55rem;
    background: #1893fc;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    // font-size: 0.225014rem;
    font-size: 12px;
    margin: 0;
  }
}

.disabled_button {
  background: #cbced3 !important;
  color: #666 !important;
}

.table_popover {
  .el-table {
    border: 1px solid #e3e3e3;
    box-sizing: border-box;

    th,
    td {
      padding: 0;
      color: #666;
      box-sizing: border-box;
      border-right: 1px solid #e3e3e3;

      .cell {
        // height: 0.562535rem;
        height: 0.55rem;
        display: flex;
        align-items: center;
        // font-size: 0.225014rem;
        font-size: 12px;
      }

      &:first-child {
        .cell {
          justify-content: center;
        }
      }

      &:last-child {
        border-right: none;
      }
    }

    th {
      .cell {
        background: #ededed;
        justify-content: center;
      }
    }

    .el-table__body tr:hover > td {
      background: #e3f6ff;
    }

    .el-table__footer-wrapper {
      td {
        background: #f4f4f4;
        border: none;
      }
    }

    //滚动条的宽度
    ::-webkit-scrollbar {
      width: 10px;
      height: 10px;
      background-color: #e5e5e5;
    }

    //滚动条的滑块
    ::-webkit-scrollbar-thumb {
      background-color: #c9c9c9;
    }
  }

  .new_table_style {
    // height: 0.562535rem;
    height: 0.55rem;
    border: 1px solid #e3e3e3;
    border-top: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ededed;
  }
}

//
//-------自定义-------
//
.custom_star {
  display: flex;
  align-items: center;
  margin-right: 6px;
}

.star {
  color: red;
  // position: absolute;
  // margin-left: -10px;
}

.bottom_item {
  margin: 30px 0;
  width: 100%;
  text-align: center;
}

.custom_select_head {
  // right: 10px;
  width: 150px;
  height: 100%;
  position: relative;
}

.custom_more {
  position: absolute;
  right: 10px;
  z-index: 10;
  top: 1px;
  background: #fff;
  height: 28px;
  display: flex;
  align-items: center;
  color: #bfbfbf;
}

.custom_add {
  display: flex;
  justify-content: center;
  align-items: center;

  span {
    margin-left: 5px;
    color: #666666;
  }

  i {
    color: #666666;
  }
}

.cus_div {
  display: flex;
  align-items: center;
  margin-left: 5px;
}

.custom_left {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
}

.custom_item {
  display: flex;
  align-items: center;
  margin: 5px 20px 5px 0;
}
.open-account {
  color: #fd6c21;
  font-size: 12px;
  height: 100%;
  display: flex;
  align-items: center;
}
.custom_select_head_time {
  width: 100%;
  height: 100%;
  position: relative;
}
</style>
